package by.euanpa.android.grodnobusstop.location;

import android.content.Context;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Looper;

public class LocationHelper {

	public static final String SERVICE_NAME = "euanpa_location_helper";

	protected LocationManager locationManager;

	public LocationHelper(Context context) {
		locationManager = (LocationManager) context.getSystemService(Context.LOCATION_SERVICE);
	}

	public void requestLocation(LocationListener listener) {
		if (locationManager.isProviderEnabled(LocationManager.NETWORK_PROVIDER)) {
			locationManager.requestSingleUpdate(LocationManager.NETWORK_PROVIDER, listener, Looper.getMainLooper());
		} else{
		}
	}
	
	public static LocationHelper get(Context context) {
		return (LocationHelper) context.getApplicationContext().getSystemService(SERVICE_NAME);
	}
}